<template>
		<view class="all">
				<cu-custom bgColor="bg-white" :isBack="true">
					<block slot="content"></block>
				</cu-custom>
				<view class="text">欢迎使用<text class="text2">实训管家</text></view>
				<view class="sq">授权微信头像、昵称</view>
				<view class="p">
					<view class="iconfont icon-shixisheng"></view>
					<view class="c">实训管家</view>
					
				</view>
				
				<button class="cu-btn bg-blue lg" @tap="login"><image src="../../static/wx.png"></image>微信授权登录</button>
				<view class="tip">
					<text class="black">登录代表您已同意</text>
					<text class="blue">《用户服务协议》</text>
					<text class="blue">《隐私权政策》</text>
					
					
				</view>
				
		</view>
</template>

<script>
	const {appLogin,httpGet,httpPost} = require("@/utils/common.js")
	export default {
		data() {
			return {
				code:""
			}
		},
		onLoad(){
					this.getCode()
				},
		methods: {
			getCode(){
						uni.login({
							success:(res)=>{
								this.code = res.code
							}
						})	
					},
			login(){
							console.log('点击了按钮')
							var postdata = {};
							uni.getUserProfile({
								desc:'先授权登录',
								success:(res)=>{
									console.log(res)
									postdata.encryptedData = res.encryptedData
									postdata.iv = res.iv
									postdata.code = this.code
									console.log(postdata)
									httpPost({
										url:'/api/wx_app_login',
										data:postdata,
										success(res) {		
											console.log(res)
										}
									})
								}
							})
							uni.reLaunch({
								url:"./home"
							})
					}	
		}
	}
</script>

<style>
.all{
	background-color: white;
	width: 825rpx;
	height: 1330rpx;
}
.text{
	padding: 80rpx 30rpx 30rpx 30rpx;
	font-size: 50rpx;
	
}
.text2{
	padding: 20rpx;
	
}
.sq{
	font-size: 30rpx;
	color:gray;
	padding: 0rpx 0rpx 0rpx 30rpx;
}
.icon-shixisheng{
	font-size: 250rpx;
	color:blue;
	
}
.icon-weixin{
	font-size: 20rpx;
}
.p{
	padding:80rpx 0rpx 100rpx 250rpx;
}
.c{
	font-size: 50rpx;
	color:blue;
	padding: 0rpx 0rpx 0rpx 30rpx;
}
.cu-btn >image{
	width: 50rpx;
	height: 50rpx;
	color: white;
}
.cu-btn{
	width:700rpx;
	margin-left: 20rpx;
	
}
.tip{
	padding:250rpx 0rpx 0rpx 80rpx;
}
.black{
	font-size: 25rpx;
}
.blue{
	color:blue;
}
</style>
